import { defineStore } from "pinia";
import { Pen } from "@topology/core";

const useCurComponent = defineStore("curComponent", {
	// 推荐使用 完整类型推断的箭头函数
	state: (): {
		curComponentId: string[]
		curComponent: Pen[];
	} => {
		return {
			// 所有这些属性都将自动推断其类型
			curComponentId: [],
			curComponent: [],
		};
	},
	getters: {
		getCurComponent: (state) => state.curComponent,
		getCurComponentId: (state) => state.curComponentId,
	},
	actions: {
		changeCurComponent(data: Pen[]) {
			this.curComponent = [...data];
			this.curComponentId= data.map(item => item.id!)
		},
	},
});
export default useCurComponent;
